package me.hetong.caigou.animate;

import animatefx.animation.AnimationFX;
import animatefx.animation.FadeIn;
import javafx.animation.FadeTransition;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.layout.Pane;
import javafx.util.Duration;

public class AnimateUtils {
    public AnimateUtils(Pane pane, long time, EventHandler<ActionEvent> finish) {

        FadeTransition fadeTransition = new FadeTransition(Duration.millis(time), pane);
        fadeTransition.setFromValue(0.0);
        fadeTransition.setToValue(1.0);
        if (finish != null) {
            fadeTransition.setOnFinished(finish);
        }
        fadeTransition.play();
    }

    public static void a1(AnimationFX animationFX, EventHandler<ActionEvent> finish) {
        animationFX.setOnFinished(finish);
        animationFX.play();
    }
}
